<%@page import="com.situ.web.entity.Student"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="lib/bootstrap-3.3.7-dist/css/bootstrap.css" />
</head>
<body>
<%-- 	${student} --%>
<div id="updateId">
	<form id="ajax_form" method="post"  onsubmit="return false"> 
		<input type="hidden" name="id" value="${student.id}" /> 
		用户名:<input type="text" name="name" value="${student.name}"/><br /><br />
		年&nbsp;&nbsp;&nbsp;龄:<input type="text" name="age"  value="${student.age}"/><br /><br />
		性&nbsp;&nbsp;&nbsp;别:<input type="text" name="gender" value="${student.gender}"/><br /><br />
		<input type="button"  onclick="submitForm()" value="修改" class="btn btn-success"/>
	</form>
	
	<script src="js/jquery-1.11.3.js" type="text/javascript" charset="utf-8"></script>
	<script src="lib/layer/layer.js" type="text/javascript" charset="utf-8"></script>
	<script src="lib/mylayer.js" type="text/javascript" charset="utf-8"></script>
	<script src="lib/util.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		function submitForm(){
			$.ajax({
				url:"${pageContext.request.contextPath}/student?method=update",
				type:"post",
				dataType:"json",
				data:$("#ajax_form").serialize(),
				success : function(jsonObj) {
					if(jsonObj.code == util.SUCCESS){
						mylayer.successMsg(jsonObj.msg);
						//当你在iframe页面关闭自身时
						var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
						setTimeout(function(){
							parent.layer.close(index); //再执行关闭 
							// 刷新父页面
							window.parent.location.reload();
						},1000);
					} else {
						mylayer.errorMsg(jsonObj.msg);
					}
				}
			});
		}
	</script>
</div>	
</body>
</html>